package com.hl.sfzy.interceptor;

import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.List;

public class InterceptorLogin implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        List<String> excludePath = new ArrayList<>();
        //  登录
        String login = "/user/login";
        // 发送短信码
        String getVerifyCode = "/common/send";
        // 验证码
        String verfifyMethod = "/common/validationCode";
        String error = "/error";
        // 排除路径
        excludePath.add(login);
        excludePath.add(getVerifyCode);
        excludePath.add(verfifyMethod);
        excludePath.add(error);
        // 配置token拦截器
        registry.addInterceptor(new TokenHandler()).excludePathPatterns(excludePath);
    }
}
